Skip to content

Conversation

@summerDev96
Copy link
Collaborator

@summerDev96 summerDev96 commented Jul 28, 2025

📦 Pull Request

📝 요약(Summary)

새로 브랜치를 생성하여 다시 PR 올렸습니다.
기존 PR 코드에서 수정된 부분들이 많아 다시 확인부탁드립니다!

  • 서버 사이드 렌더링 시 오류가 있어 쿠키를 저장하는 방식으로 변경되었습니다
  • apiClient 파일에서 서버사이드 렌더링 시 createApiClient함수에서 context를 받아 인스턴스를 생성하게 수정하였습니다.
  • 리프레쉬 토큰 갱신 관련 로직 서버사이드 렌더링시에도 공통적으로 적용되도록 추가하였습니다
  • 테스트 페이지 생성하여 getServerSideProps로 유저 데이터 받아오는 것 테스트하였습니다. (/test/index.tsx)
  • 쿠키를 가져오는 메소드들을 파일 안에 추가하였습니다. (/lib/cookie.ts)

💬 공유사항 to 리뷰어

서버 사이드 렌더링 사용하시는 분들 머지 완료되시면 테스트 필요할 것 같습니다

환경변수 추가 필요
NEXT_PUBLIC_API_URL 추가 필요합니다.

NEXT_PUBLIC_BASE_URL=https://winereview-api.vercel.app
NEXT_PUBLIC_TEAM=16-4
NEXT_PUBLIC_KAKAO_APP_KEY=7b5c127406934830bcf7710ee83e9094
NEXT_PUBLIC_KAKAO_REDIRECT_URI=http://localhost:3000/oauth/signup/kakao
NEXT_PUBLIC_API_URL=http://localhost:3000

클라이언트에서만 사용하는 api
기존 apiClient 그대로 두면 됩니다.

export const createUser = (data: SignupRequest): Promise<SignupResponse> => {
  return apiClient.post(`/${process.env.NEXT_PUBLIC_TEAM}/auth/signUp`, data);
};

서버 사이드 렌더링 사용하는 api
createApiClient로 변경 필요합니다.
parameter로 context를 넘겨야 합니다.

export const getUser = (context?: GetServerSidePropsContext): Promise<GetUserResponse> => {
  return createApiClient(context).get(`/${process.env.NEXT_PUBLIC_TEAM}/users/me`);
};

🗂️ 관련 이슈

Refs #70

📸 스크린샷

✅ 체크리스트

  • 빌드 및 테스트 통과
  • ESLint/Prettier 검사 통과

@vercel
Copy link

vercel bot commented Jul 28, 2025

@summerDev96 is attempting to deploy a commit to the 626-ju's projects Team on Vercel.

A member of the Team first needs to authorize it.


export function setServerCookie({ response, name, value, maxAge }: SetServerCookieParams) {
const cookie = `${name}=${encodeURIComponent(value)}; Path=/; Max-Age=${maxAge}; SameSite=Lax; Secure; HttpOnly`;

Copy link
Collaborator

@626-ju 626-ju Jul 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!
테스트용 코드랑 전체적으로 큰 흐름은 비슷한 것 같습니다
함수를 어떻게 분리했는지 이런 세세한 것만 조금 다른 것 같아요

근데 여기서 httpOnly를 추가해서 보내버리면
겟 서버사이드 프롭스를 통해 이걸 사용한 페이지가 렌더 된 후
->
나중에 로그아웃할 때 로컬에서 강제로 쿠키에 접근해 삭제해야 할텐데 문제 없이 접근할 수 있나요???
저도 잘 모르겠어서 멘토님께 여쭤보고 피드백 받거나
직접 실험해봐야지 확실히 알 수 있을 거 같습니다.

그리고 SameSite =Lax
-> 이것도 다른 사이트에서 이미지를 가져올 때(get) 쿠키를 안보낸다고 하는데
-> 오늘 이미지 화면에 뿌려보니까 s3 아마존 어쩌구에서 받아서 오더라구요?
(sprint-fe-project.s3.ap-northeast-2.amazonaws.com)
이 경우에 안 걸리는지도 확인해봐야 할 것 같아요.
->만약 걸려서 요청이 제대로 안 보내진다면? none으로 설정해야 할텐데... 다른 방법이 있는지 여쭤보는 것도 좋을 것 같습니다

@summerDev96 summerDev96 merged commit 9525558 into codeit-part3-7:dev Jul 30, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants